//
//  LSAPIManager.m
//  ZLFastDoctor
//
//  Created by 李宗帅 on 16/5/21.
//  Copyright © 2016年 LS. All rights reserved.
//

#import "LSAPIManager.h"
#import "LSHTTPManager.h"
#import <AFNetworking/AFHTTPSessionManager.h>
#import <ShareSDK/SSDKCredential.h>
#import <YYModel/YYModel.h>
@implementation LSAPIManager


+ (instancetype)sharedManager {
    static dispatch_once_t onceToken;
    static LSAPIManager *manager;
    dispatch_once(&onceToken, ^{
        manager = [[self alloc]init];
    });
    
    return manager;
}

// 疾病细分数据请求
- (void)requestSickSegment:(NSString *)api parameters:(id)parameters Completion:(void(^)(id responseObject, NSError *error))completion {
    [[LSHTTPManager sharedManager] POST:@"doctor/searchCI3List.json.php" parameters:parameters comletionHandle:completion];
}
// 疾病并发请求
- (void)requestSickComplication:(NSString *)api parameters:(id)parameters Completion:(void(^)(id responseObject, NSError *error))completion {
    [[LSHTTPManager sharedManager] POST:@"doctor/complicationList.json.php" parameters:parameters comletionHandle:completion];
}
// 医生列表请求
- (void)requestDoctor:(NSString *)api parameters:(id)parameters Completion:(void(^)(id responseObject, NSError *error))completion {
    [[LSHTTPManager sharedManager] POST:@"matchDoctors.json.php" parameters:parameters comletionHandle:completion];
}

// 医生基本信息请求
- (void)requestDoctorInfo:(NSString *)api parameters:(id)parameters Completion:(void(^)(id responseObject, NSError *error))completion {
    [[LSHTTPManager sharedManager] POST:@"getDoctorInfo.json.php" parameters:parameters comletionHandle:completion];
}

//请求QQ基本信息数据

+ (void)requestQQcredential:(SSDKCredential *)credential completion:(void(^)(NSMutableDictionary *))completion {
    
    NSString *urlString = [NSString stringWithFormat:@"https://graph.qq.com/user/get_simple_userinfo?access_token=%@&oauth_consumer_key=100371282&openid=%@",credential.token,credential.uid];
    
    AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
    manager.requestSerializer = [AFJSONRequestSerializer serializer];
    
   manager.responseSerializer.acceptableContentTypes = [NSSet setWithObjects:@"application/json", @"text/json", @"text/javascript" ,@"text/html", nil];
    
    [manager GET:urlString parameters:nil progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
        
        completion(responseObject);
        
    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
    }];
    
}
@end




